package com.lagou.edu.controller;

import com.lagou.edu.dao.InfoDao;
import com.lagou.edu.zk.ZkHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class IndexController {
    @Autowired
    private InfoDao infoDao;

    @ResponseBody
    @GetMapping("/")
    public String index(HttpServletResponse response) throws IOException {
        return infoDao.getNow();
    }


    @ResponseBody
    @GetMapping("/modify")
    public String modifyDateSource(String p) {
        ZkHelper.modifyDataSource("localhost:3307", "root", "root");
        return "Done";
    }
}
